/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package worms;

import java.util.Random;

/**
 *
 * @author isen
 */
public class Player {

    private String name;
    private int numberOfVictory;
    private int numberOfWormsAlive;
    private boolean loose = false;
    private GameGrid carte;
    private Warior sniper;
    private Warior assaut;

    Player(String name) {
        this.name = name;

    }

    Player(String name, GameGrid carte) {
        this.carte = carte;
        this.name = name;
        this.numberOfVictory = 0;
        this.numberOfWormsAlive = 2;


    }

    public void placeWorms() {
        int test = 0;
        do {
            this.assaut = new Warior(name + "_ASSAUT", 4, getCarte());
            test++;
        } while (this.getAssaut().addWarrior() == 0 && test < 10);
        test = 0;
        do {
            this.sniper = new Warior(name + "_SNIPER", 2, getCarte());
            test++;
        } while (this.getSniper().addWarrior() == 0 && test < 10);
        sniper.proprietaire = this;
        assaut.proprietaire = this;
    }

    public boolean loose() {
        if (this.numberOfWormsAlive == 0) {
            this.loose = true;
        }
        return this.loose;
    }

    public void afficherCarte() {
        System.out.println("Carte de\t" + this.name);
        this.getCarte().printMap(this);
    }

    /**
     * @return the sniper
     */
    public Warior getSniper() {
        return sniper;
    }

    /**
     * @return the assaut
     */
    public Warior getAssaut() {
        return assaut;
    }

    /**
     * @return the carte
     */
    public GameGrid getCarte() {
        return carte;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumberOfVictory() {
        return numberOfVictory;
    }

    public void setNumberOfVictory(int numberOfVictory) {
        this.numberOfVictory = numberOfVictory;
    }

    public int getNumberOfWormsAlive() {
        return numberOfWormsAlive;
    }

    public void setNumberOfWormsAlive(int numberOfWormsAlive) {
        this.numberOfWormsAlive = numberOfWormsAlive;
    }
}
